package com.appspot.yttv.client;

import com.appspot.yttv.client.model.StationSource;

/**
 * Converts a SourceEntry to its model.
 * 
 * @author Ramona Bobohalma
 */
public class StationSourceConverter {
	
	private static final String CHANNEL = "channel";
	private static final String CATEGORY = "category";
	private static final String PLAYLIST = "playlist";
	private static final String SEARCH = "search";
	
	public StationSource toModel(StationSourceEntry entry) {
		String type = entry.getType();
		if (CATEGORY.equals(type)) {
			return StationSource.forCategory(entry.getContentId());
		} else if (CHANNEL.equals(type)) {
			return StationSource.forChannel(entry.getContentId());
		} else if (PLAYLIST.equals(type)) {
			return StationSource.forPlaylist(entry.getContentId());
		} else if (SEARCH.equals(type)) {
			return StationSource.forSearch(entry.getContentId());
		} 
		return null;
	}
}
